\doxysection{bsp\+\_\+can.\+h}
\hypertarget{bsp__can_8h_source}{}\label{bsp__can_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/can/bsp\_can.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/can/bsp\_can.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ BSP\_CAN\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ BSP\_CAN\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{fdcan_8h}{fdcan.h}}"{}}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{comment}{//\ 最多能够支持的CAN设备数}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#define\ CAN\_MX\_REGISTER\_CNT\ 16\ \ \ \ \ }\textcolor{comment}{//\ 这个数量取决于CAN总线的负载}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#define\ MX\_CAN\_FILTER\_CNT\ (2\ *\ 14)\ }\textcolor{comment}{//\ 最多可以使用的CAN过滤器数量,目前远不会用到这么多}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#define\ DEVICE\_CAN\_CNT\ 3\ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{//\ 根据板子设定,F407IG有CAN1,CAN2,因此为2;F334只有一个,则设为1}}
\DoxyCodeLine{00011\ \textcolor{comment}{//\ 如果只有1个CAN,还需要把bsp\_can.c中所有的hcan2变量改为hcan1(别担心,主要是总线和FIFO的负载均衡,不影响功能)}}
\DoxyCodeLine{00012\ }
\DoxyCodeLine{00013\ \textcolor{comment}{/*\ can\ instance\ typedef,\ every\ module\ registered\ to\ CAN\ should\ have\ this\ variable\ */}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#pragma\ pack(1)}}
\DoxyCodeLine{00015\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{struct__}{\_}}}
\DoxyCodeLine{00016\ \{}
\DoxyCodeLine{00017\ \ \ \ \ FDCAN\_HandleTypeDef\ *can\_handle;\ \textcolor{comment}{//\ can句柄}}
\DoxyCodeLine{00018\ \ \ \ \ FDCAN\_TxHeaderTypeDef\ txconf;\ \ \ \ \textcolor{comment}{//\ CAN报文发送配置}}
\DoxyCodeLine{00019\ \ \ \ \ uint32\_t\ tx\_id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 发送id}}
\DoxyCodeLine{00020\ \ \ \ \ uint32\_t\ tx\_mailbox;\ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ CAN消息填入的邮箱号}}
\DoxyCodeLine{00021\ \ \ \ \ uint8\_t\ tx\_buff[8];\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 发送缓存,发送消息长度可以通过CANSetDLC()设定,最大为8}}
\DoxyCodeLine{00022\ \ \ \ \ uint8\_t\ rx\_buff[8];\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收缓存,最大消息长度为8}}
\DoxyCodeLine{00023\ \ \ \ \ uint32\_t\ rx\_id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收id}}
\DoxyCodeLine{00024\ \ \ \ \ uint8\_t\ rx\_len;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收长度,可能为0-\/8}}
\DoxyCodeLine{00025\ \ \ \ \ \textcolor{comment}{//\ 接收的回调函数,用于解析接收到的数据}}
\DoxyCodeLine{00026\ \ \ \ \ void\ (*can\_module\_callback)(\textcolor{keyword}{struct\ }\mbox{\hyperlink{struct__}{\_}}\ *);\ \textcolor{comment}{//\ callback\ needs\ an\ instance\ to\ tell\ among\ registered\ ones}}
\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keywordtype}{void}\ *id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 使用can外设的模块指针(即id指向的模块拥有此can实例,是父子关系)}}
\DoxyCodeLine{00028\ \}\ CANInstance;}
\DoxyCodeLine{00029\ \textcolor{preprocessor}{\#pragma\ pack()}}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \textcolor{comment}{/*\ CAN实例初始化结构体,将此结构体指针传入注册函数\ */}}
\DoxyCodeLine{00032\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00033\ \{}
\DoxyCodeLine{00034\ \ \ \ \ FDCAN\_HandleTypeDef\ *can\_handle;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ can句柄}}
\DoxyCodeLine{00035\ \ \ \ \ uint32\_t\ tx\_id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 发送id}}
\DoxyCodeLine{00036\ \ \ \ \ uint32\_t\ rx\_id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收id}}
\DoxyCodeLine{00037\ \ \ \ \ void\ (*can\_module\_callback)(CANInstance\ *);\ \textcolor{comment}{//\ 处理接收数据的回调函数}}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordtype}{void}\ *id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 拥有can实例的模块地址,用于区分不同的模块(如果有需要的话),如果不需要可以不传入}}
\DoxyCodeLine{00039\ \}\ \mbox{\hyperlink{struct_c_a_n___init___config__s}{CAN\_Init\_Config\_s}};}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00047\ CANInstance\ *CANRegister(\mbox{\hyperlink{struct_c_a_n___init___config__s}{CAN\_Init\_Config\_s}}\ *config);}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00055\ \textcolor{keywordtype}{void}\ CANSetDLC(CANInstance\ *\_instance,\ uint8\_t\ length);}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00066\ uint8\_t\ CANTransmit(CANInstance\ *\_instance,\textcolor{keywordtype}{float}\ timeout);}
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00068\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
